package framework.ia;

import org.newdawn.slick.GameContainer;

import framework.BasicFighter;
import framework.Controls;
import framework.collision.AttackCollisionManager;

public class FollowAndAttackBrain extends Brain {
	
	public BasicFighter fighter2;
	
	AttackCollisionManager collisions;

	public FollowAndAttackBrain(BasicFighter fighter, BasicFighter fighter2) {
		super(fighter);
		this.fighter2 = fighter2;
	}
	
	@Override
	public void update(GameContainer gc, int delta) {
	    if(Math.abs(getHostFighter().getHitBox().getCenterX() - fighter2.getHitBox().getCenterX()) <= 100) {
	    	getHostFighter().attack(getHostFighter().getAttacks().getAttack(Controls.A_P2));
	    } else {
	    	getHostFighter().move(getHostFighter().isForward());
	    }
	}

	public AttackCollisionManager getCollisions() {
		return collisions;
	}

	public void setCollisions(AttackCollisionManager collisions) {
		this.collisions = collisions;
	}
}
